Auto merge of #3611 - tylerwhall:stable-metadata, r=alexcrichton
authorbors <bors@rust-lang.org>
Wed, 9 Aug 2017 14:10:12 +0000 (14:10 +0000)
committerbors <bors@rust-lang.org>
Wed, 9 Aug 2017 14:10:12 +0000 (14:10 +0000)
commitd2e8587dc459d79045675ce721c3ef06220d7c67
tree9244b106a1b21b89a28427ba47febadcbfd54bc8
parentfe56d43b0afbe06709900b4dab4123655929a0e2
parenteb0e4c0b1180b63be74fda649d5f4994b0955199
Auto merge of #3611 - tylerwhall:stable-metadata, r=alexcrichton

Stable metadata hashes across workspaces

Currently a crate from a path source will have its metadata hash incorporate its absolute path on the system where it is built. This always impacts top-level crates, which means that compiling the same source with the same dependencies and compiler version will generate libraries with symbol names that vary depending on where the workspace resides on the machine.

This is hopefully a general solution to the hack we've used in meta-rust to make dynamic linking reliable.
meta-rust/meta-rust@0e6cf94

For paths inside the Cargo workspace, hash their SourceId relative to the root of the workspace. Paths outside of a workspace are still hashed as absolute.

This stability is important for reproducible builds as part of a larger build system that employs caching of artifacts, such as OpenEmbedded.

OpenEmbedded tightly controls all inputs to a build and its caching assumes that an equivalent artifact will always result from the same set of inputs. The workspace path is not considered to be an influential input, however.

For example, if Cargo is used to compile libstd shared objects which downstream crates link to dynamically, it must be possible to rebuild libstd given the same inputs and produce a library that is at least link-compatible with the original. If the build system happens to cache the downstream crates but needs to rebuild libstd and the user happens to be building in a different workspace path, currently Cargo will generate a library incompatible with the original and the downstream executables will fail at runtime on the target.
src/cargo/ops/cargo_rustc/context.rs
src/cargo/ops/cargo_rustc/mod.rs
tests/build.rs
tests/path.rs